﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Str2SbCollection
{
    public partial class frmPlus : Form
    {
        public frmPlus()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            txtSb.Text = "";
            string strTxt = txtStr.Text;

            string[] txts = strTxt.Split('+');

            string result;

            if (btn.Name == "btnNoClear")
                result = "";
            else
                result = "sb.Clear();\n";

            foreach (string txt in txts)
            {
                string txtdd = txt.Trim();

                if (txtdd.Length <= 0)
                    continue;
                if (txtdd.Length > 0 && txtdd[txtdd.Length - 1] == ';')
                    txtdd = txtdd.Substring(0, txtdd.Length - 1);

                result += "sb.Append(" + txtdd + ");\n";
            }
            txtSb.Text = result;

            Clipboard.SetDataObject(result);
        }

        private void txtStr_Click(object sender, EventArgs e)
        {
            txtStr.SelectAll();
        }

        private void txtSb_Click(object sender, EventArgs e)
        {
            txtSb.SelectAll();
        }
    }
}
